package com.lanou.userLogin.order.web.servlet;

import com.lanou.userLogin.order.domain.Order;
import com.lanou.userLogin.order.domain.OrderBook;
import com.lanou.userLogin.order.service.OrderService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/myOrderPayServlet")
public class MyOrderPayServlet extends HttpServlet {

    private OrderService os = new OrderService();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //获取想支付的oid
        String oid = req.getParameter("oid");

        //根据oid查询订单和对应的订单项，转发到订单结算页面
        Order order = os.selectOrderByoid(oid);
        List<OrderBook> orderBook = os.selectOrderBook(oid);
        req.setAttribute("order", order);
        req.setAttribute("orderbook", orderBook);
        req.getRequestDispatcher("/jsps/order/desc.jsp").forward(req, resp);
    }
}
